"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.地灵Handler = void 0;
const Config_1 = require("../../Config");
const Big_1 = require("../core/Big");
const Point_1 = require("../core/Point");
const GameUtils_1 = __importDefault(require("../GameUtils"));
const BaseHandler_1 = require("./BaseHandler");
class 地灵Handler extends BaseHandler_1.BaseHandler {
    /** 大子移动 */
    move(data, player) {
        this.handlerMgr.spendAction(player, Config_1.Config.COST_BIG_MOVE);
        let startPoint = this.gameMgr.map_point.get(data.start);
        let endPoint = this.gameMgr.map_point.get(data.end);
        let big_start = startPoint.big;
        big_start.actionOnce();
        let big_end = endPoint.big;
        if (big_end != null) {
            big_end.deleteState(Big_1.BigState.HIDE);
            big_start.die(player, endPoint.id);
            return;
        }
        startPoint.big = null;
        endPoint.big = big_start;
        big_start.point = endPoint;
        this.gameMgr.sendBroadcast(GameUtils_1.default.getObj("big_move", { "start": data.start, "end": data.end }));
    }
    地灵_抹平(data, player) {
        this.handlerMgr.spendAction(player, Config_1.Config.COST_地灵_抹平);
        let startPoint = this.gameMgr.map_point.get(data.start);
        let endPoint = this.gameMgr.map_point.get(data.end);
        let big_start = startPoint.big;
        big_start.actionOnce();
        let big_end = endPoint.big;
        if (big_end != null) {
            big_end.deleteState(Big_1.BigState.HIDE);
            big_start.die(player, endPoint.id);
            return;
        }
        startPoint.big = null;
        endPoint.big = big_start;
        big_start.point = endPoint;
        this.gameMgr.sendBroadcast(GameUtils_1.default.getObj("地灵_抹平", { "start": data.start, "end": data.end }));
        endPoint.changeTerrain(Point_1.Terrain.KONG);
    }
    地灵_占据(data, player) {
        this.handlerMgr.spendAction(player, Config_1.Config.COST_地灵_占据);
        let startPoint = this.gameMgr.map_point.get(data.start);
        let endPoint = this.gameMgr.map_point.get(data.end);
        let big_start = startPoint.big;
        big_start.actionOnce();
        let big_end = endPoint.big;
        if (big_end != null) {
            big_end.attacked(player);
        }
        startPoint.big = null;
        endPoint.big = big_start;
        big_start.point = endPoint;
        this.gameMgr.sendBroadcast(GameUtils_1.default.getObj("地灵_占据", { "start": data.start, "end": data.end }));
    }
}
exports.地灵Handler = 地灵Handler;
